this.BX=this.BX||{};this.BX.Location=this.BX.Location||{};(function(e,a,t){"use strict";function l(e,a,t,l){if(e!==a){throw new TypeError("Private static access of wrong provenance")}if(t.set){t.set.call(e,l)}else{if(!t.writable){throw new TypeError("attempted to set read only private field")}t.value=l}return l}function i(e,a,t){if(e!==a){throw new TypeError("Private static access of wrong provenance")}return t}function r(e,a,t){if(e!==a){throw new TypeError("Private static access of wrong provenance")}if(t.get){return t.get.call(e)}return t.value}var s=function(){function e(){babelHelpers.classCallCheck(this,e)}babelHelpers.createClass(e,null,[{key:"load",value:function a(t,s){return new Promise(function(a){if(r(e,e,o)){a()}BX.load([i(e,e,n).call(e,t,s)],function(){l(e,e,o,true);a()})})}}]);return e}();var n=function e(a,t){return"https://maps.googleapis.com/maps/api/js?key="+a+"&libraries=places&language="+t};var o={writable:true,value:false};function b(e,a,t){if(!a.has(e)){throw new TypeError("attempted to get private field on non-instance")}return t}var c=function(){function e(a){var t=this;babelHelpers.classCallCheck(this,e);y.add(this);m.add(this);P.add(this);g.add(this);w.add(this);H.add(this);u.set(this,{writable:true,value:void 0});d.set(this,{writable:true,value:void 0});v.set(this,{writable:true,value:void 0});p.set(this,{writable:true,value:void 0});h.set(this,{writable:true,value:"locationGoogleAutocomplete"});f.set(this,{writable:true,value:30});babelHelpers.classPrivateFieldSet(this,u,a.languageId);babelHelpers.classPrivateFieldSet(this,p,a.source);babelHelpers.classPrivateFieldSet(this,v,a.loaderPromise.then(function(){b(t,m,G).call(t)}))}babelHelpers.createClass(e,[{key:"autocomplete",value:function e(a,t){var l=this;return babelHelpers.classPrivateFieldGet(this,v).then(function(){return b(l,P,T).call(l,a,t)},function(e){return BX.debug(e)})}}]);return e}();var u=new WeakMap;var d=new WeakMap;var v=new WeakMap;var p=new WeakMap;var h=new WeakMap;var f=new WeakMap;var H=new WeakSet;var w=new WeakSet;var g=new WeakSet;var P=new WeakSet;var m=new WeakSet;var y=new WeakSet;var F=function e(a,t){var l=null,i=localStorage.getItem(babelHelpers.classPrivateFieldGet(this,h));if(i){try{i=JSON.parse(i)}catch(e){return null}if(Array.isArray(i)){var r=true;var s=false;var n=undefined;try{for(var o=i.entries()[Symbol.iterator](),b;!(r=(b=o.next()).done);r=true){var c=babelHelpers.slicedToArray(b.value,2),u=c[0],d=c[1];if(d&&typeof d.query!=="undefined"&&d.query===a){l=Object.assign({},d);i.splice(u,1);i.push(l);localStorage.setItem(babelHelpers.classPrivateFieldGet(this,h),JSON.stringify(i));break}}}catch(e){s=true;n=e}finally{try{if(!r&&o.return!=null){o.return()}}finally{if(s){throw n}}}}}return l};var S=function e(a,t){var l=this;var i=null,r=b(this,H,F).call(this,a,t);if(r!==null){i=new Promise(function(e){e(b(l,y,I).call(l,r.answer,r.status))})}return i};var k=function e(a,t,l,i){var r=localStorage.getItem(babelHelpers.classPrivateFieldGet(this,h));if(r){try{r=JSON.parse(r)}catch(e){return}}if(!Array.isArray(r)){r=[]}r.push({status:i,query:a,answer:l});if(r.length>babelHelpers.classPrivateFieldGet(this,f)){r.shift()}localStorage.setItem(babelHelpers.classPrivateFieldGet(this,h),JSON.stringify(r))};var T=function e(a,t){var l=this;var i=b(this,w,S).call(this,a,t);if(!i){i=new Promise(function(e){babelHelpers.classPrivateFieldGet(l,d).getQueryPredictions({input:a},function(i,r){var s=b(l,y,I).call(l,i,r);b(l,g,k).call(l,a,t,i,r);e(s)})})}return i};var G=function e(){if(typeof google==="undefined"||typeof google.maps.places.AutocompleteService==="undefined"){throw new Error("google.maps.places.AutocompleteService must be defined")}babelHelpers.classPrivateFieldSet(this,d,new google.maps.places.AutocompleteService)};var I=function e(a,l){if(l==="ZERO_RESULTS"){return[]}if(!a||l!=="OK"){return false}var i=[];var r=true;var s=false;var n=undefined;try{for(var o=a[Symbol.iterator](),b;!(r=(b=o.next()).done);r=true){var c=b.value;var d=new t.Location({sourceCode:babelHelpers.classPrivateFieldGet(this,p).sourceCode,externalId:c.place_id,name:c.description,languageId:babelHelpers.classPrivateFieldGet(this,u)});i.push(d)}}catch(e){s=true;n=e}finally{try{if(!r&&o.return!=null){o.return()}}finally{if(s){throw n}}}return i};function W(e,a,t){if(e!==a){throw new TypeError("Private static access of wrong provenance")}if(t.get){return t.get.call(e)}return t.value}function z(e,a,t){if(!a.has(e)){throw new TypeError("attempted to get private field on non-instance")}return t}var M=function(e){babelHelpers.inherits(a,e);function a(e){var l;babelHelpers.classCallCheck(this,a);l=babelHelpers.possibleConstructorReturn(this,babelHelpers.getPrototypeOf(a).call(this,e));ee.add(babelHelpers.assertThisInitialized(l));$.add(babelHelpers.assertThisInitialized(l));Y.add(babelHelpers.assertThisInitialized(l));V.add(babelHelpers.assertThisInitialized(l));Q.add(babelHelpers.assertThisInitialized(l));U.add(babelHelpers.assertThisInitialized(l));K.add(babelHelpers.assertThisInitialized(l));q.add(babelHelpers.assertThisInitialized(l));j.add(babelHelpers.assertThisInitialized(l));J.add(babelHelpers.assertThisInitialized(l));C.set(babelHelpers.assertThisInitialized(l),{writable:true,value:void 0});E.set(babelHelpers.assertThisInitialized(l),{writable:true,value:void 0});L.set(babelHelpers.assertThisInitialized(l),{writable:true,value:void 0});O.set(babelHelpers.assertThisInitialized(l),{writable:true,value:void 0});Z.set(babelHelpers.assertThisInitialized(l),{writable:true,value:void 0});B.set(babelHelpers.assertThisInitialized(l),{writable:true,value:void 0});A.set(babelHelpers.assertThisInitialized(l),{writable:true,value:void 0});X.set(babelHelpers.assertThisInitialized(l),{writable:true,value:void 0});R.set(babelHelpers.assertThisInitialized(l),{writable:true,value:void 0});_.set(babelHelpers.assertThisInitialized(l),{writable:true,value:void 0});x.set(babelHelpers.assertThisInitialized(l),{writable:true,value:void 0});N.set(babelHelpers.assertThisInitialized(l),{writable:true,value:""});D.set(babelHelpers.assertThisInitialized(l),{writable:true,value:false});babelHelpers.classPrivateFieldSet(babelHelpers.assertThisInitialized(l),C,e.languageId);babelHelpers.classPrivateFieldSet(babelHelpers.assertThisInitialized(l),O,e.googleSource);babelHelpers.classPrivateFieldSet(babelHelpers.assertThisInitialized(l),Z,e.zoom||10);var i=e.location||null;babelHelpers.classPrivateFieldSet(babelHelpers.assertThisInitialized(l),R,e.locationRepository||new t.LocationRepository);babelHelpers.classPrivateFieldSet(babelHelpers.assertThisInitialized(l),_,e.defaultPosition||{latitude:54.719208,longitude:20.488515});babelHelpers.classPrivateFieldSet(babelHelpers.assertThisInitialized(l),x,e.changeDelay||500);babelHelpers.classPrivateFieldSet(babelHelpers.assertThisInitialized(l),A,e.mode);babelHelpers.classPrivateFieldSet(babelHelpers.assertThisInitialized(l),L,e.loaderPromise.then(function(){z(babelHelpers.assertThisInitialized(l),Y,be).call(babelHelpers.assertThisInitialized(l),e.mapContainer,i,babelHelpers.classPrivateFieldGet(babelHelpers.assertThisInitialized(l),Z))}));return l}babelHelpers.createClass(a,[{key:"update",value:function e(a){var t=z(this,J,te).call(this,a);babelHelpers.classPrivateFieldSet(this,D,true);babelHelpers.classPrivateFieldGet(this,B).setPosition(t);babelHelpers.classPrivateFieldSet(this,D,false);babelHelpers.classPrivateFieldGet(this,E).panTo(t)}},{key:"onChangedEventSubscribe",value:function e(t){this.subscribe(W(a,a,ae),t)}},{key:"mode",set:function e(a){babelHelpers.classPrivateFieldSet(this,A,a);babelHelpers.classPrivateFieldGet(this,B).setDraggable(a===t.ControlMode.edit)}},{key:"zoom",set:function e(a){if(babelHelpers.classPrivateFieldGet(this,E)){babelHelpers.classPrivateFieldGet(this,E).setZoom(z(this,$,ce).call(this,a))}},get:function e(){if(babelHelpers.classPrivateFieldGet(this,E)){return z(this,ee,ue).call(this,babelHelpers.classPrivateFieldGet(this,E).getZoom())}}}]);return a}(a.EventEmitter);var C=new WeakMap;var E=new WeakMap;var L=new WeakMap;var O=new WeakMap;var Z=new WeakMap;var B=new WeakMap;var A=new WeakMap;var X=new WeakMap;var R=new WeakMap;var _=new WeakMap;var x=new WeakMap;var N=new WeakMap;var D=new WeakMap;var J=new WeakSet;var j=new WeakSet;var q=new WeakSet;var K=new WeakSet;var U=new WeakSet;var Q=new WeakSet;var V=new WeakSet;var Y=new WeakSet;var $=new WeakSet;var ee=new WeakSet;var ae={writable:true,value:"onChanged"};var te=function e(a){var t,l;if(a){t=a.latitude;l=a.longitude}else{t=babelHelpers.classPrivateFieldGet(this,_).latitude;l=babelHelpers.classPrivateFieldGet(this,_).longitude}return new google.maps.LatLng(t,l)};var le=function e(a){var t=this;return new Promise(function(e){babelHelpers.classPrivateFieldGet(t,X).geocode({location:a},function(a,t){if(t==="OK"&&a[0]){e(a[0].place_id)}else if(t==="ZERO_RESULTS"){e("")}else{throw Error("Geocoder failed due to: "+t)}})}).then(function(e){var a;if(e){a=babelHelpers.classPrivateFieldGet(t,R).findByExternalId(e,babelHelpers.classPrivateFieldGet(t,O).sourceCode,babelHelpers.classPrivateFieldGet(t,C))}else{a=new Promise(function(e){e(null)})}return a})};var ie=function e(a){if(babelHelpers.classPrivateFieldGet(this,A)===t.ControlMode.edit){this.emit(W(M,M,ae),{location:a})}};var re=function e(){if(!babelHelpers.classPrivateFieldGet(this,D)&&babelHelpers.classPrivateFieldGet(this,A)===t.ControlMode.edit){z(this,U,se).call(this,babelHelpers.classPrivateFieldGet(this,B).getPosition())}};var se=function e(a){var t=this;if(babelHelpers.classPrivateFieldGet(this,N)!==null){clearTimeout(babelHelpers.classPrivateFieldGet(this,N))}babelHelpers.classPrivateFieldSet(this,N,setTimeout(function(){babelHelpers.classPrivateFieldSet(t,N,null);babelHelpers.classPrivateFieldGet(t,E).panTo(a);z(t,Q,ne).call(t,a)},babelHelpers.classPrivateFieldGet(this,x)))};var ne=function e(a){z(this,j,le).call(this,a).then(z(this,q,ie).bind(this))};var oe=function e(a){if(babelHelpers.classPrivateFieldGet(this,A)===t.ControlMode.edit){babelHelpers.classPrivateFieldGet(this,B).setPosition(a);z(this,U,se).call(this,a)}};var be=function e(a,l,i){var r=this;if(typeof google==="undefined"||typeof google.maps.Map==="undefined"){throw new Error("google.maps.Map must be defined")}var s=z(this,J,te).call(this,l);babelHelpers.classPrivateFieldSet(this,E,new google.maps.Map(a,{center:s,zoom:i}));babelHelpers.classPrivateFieldGet(this,E).addListener("click",function(e){z(r,V,oe).call(r,e.latLng)});babelHelpers.classPrivateFieldGet(this,E).addListener("zoom_changed",function(e){console.log("zoom_changed");console.log(babelHelpers.classPrivateFieldGet(r,E).getZoom())});if(typeof google.maps.Marker==="undefined"){throw new Error("google.maps.Marker must be defined")}babelHelpers.classPrivateFieldSet(this,B,new google.maps.Marker({position:s,map:babelHelpers.classPrivateFieldGet(this,E),animation:google.maps.Animation.DROP,draggable:babelHelpers.classPrivateFieldGet(this,A)===t.ControlMode.edit}));babelHelpers.classPrivateFieldGet(this,B).addListener("position_changed",function(){z(r,K,re).call(r)});if(typeof google.maps.Geocoder==="undefined"){throw new Error("google.maps.Geocoder must be defined")}babelHelpers.classPrivateFieldSet(this,X,new google.maps.Geocoder)};var ce=function e(a){var l;if(a<=t.ZoomType.World)l=1;else if(a<=t.ZoomType.Country)l=4;else if(a<=t.ZoomType.Region)l=6;else if(a<=t.ZoomType.City)l=11;else if(a<=t.ZoomType.Street)l=16;else l=18;return l};var ue=function e(a){var l;if(a<=5)l=t.ZoomType.World;else if(a<=7)l=t.ZoomType.Country;else if(a<=9)l=t.ZoomType.Region;else if(a<=10)l=t.ZoomType.City;else if(a<=15)l=t.ZoomType.Street;else if(a>15)l=t.ZoomType.Building;return l};function de(e,a,t){if(!a.has(e)){throw new TypeError("attempted to get private field on non-instance")}return t}var ve=function(){function e(a){babelHelpers.classCallCheck(this,e);we.add(this);pe.set(this,{writable:true,value:"GOOGLE"});he.set(this,{writable:true,value:""});fe.set(this,{writable:true,value:null});He.set(this,{writable:true,value:null});babelHelpers.classPrivateFieldSet(this,he,a.languageId);babelHelpers.classPrivateFieldSet(this,He,s.load(a.apiKey,a.languageId))}babelHelpers.createClass(e,[{key:"createMap",value:function e(a,t,l,i){return new M({googleSource:this,languageId:babelHelpers.classPrivateFieldGet(this,he),loaderPromise:babelHelpers.classPrivateFieldGet(this,He),mapContainer:a,location:t,mode:l,zoom:i})}},{key:"autocompleter",get:function e(){if(babelHelpers.classPrivateFieldGet(this,fe)===null){babelHelpers.classPrivateFieldSet(this,fe,de(this,we,ge).call(this,babelHelpers.classPrivateFieldGet(this,he)))}return babelHelpers.classPrivateFieldGet(this,fe)}},{key:"sourceCode",get:function e(){return babelHelpers.classPrivateFieldGet(this,pe)}}]);return e}();var pe=new WeakMap;var he=new WeakMap;var fe=new WeakMap;var He=new WeakMap;var we=new WeakSet;var ge=function e(a){return new c({source:this,languageId:a,loaderPromise:babelHelpers.classPrivateFieldGet(this,He)})};var Pe=function(){function e(){babelHelpers.classCallCheck(this,e)}babelHelpers.createClass(e,null,[{key:"createSource",value:function e(a,t){if(a==="GOOGLE"){var l=Object.assign({},t);l.languageId=BX.message("LANGUAGE_ID");return new ve(l)}else{throw new Error("WrongSourceType",'Source "'+a+'" does not exist')}}}]);return e}();e.SourceFactory=Pe})(this.BX.Location.Source=this.BX.Location.Source||{},BX.Event,BX.Location.Core);
//# sourceMappingURL=source.bundle.map.js